package jintian作业;

import com.sun.org.apache.bcel.internal.generic.NEW;

import java.io.*;

/**
 * @ClassName test1
 * @Description TODO
 * @Author HP
 * @Date 8:31 2022/7/11
 * @Version 1.0
 **/
public class test {
    public static void main(String[] args) throws IOException,IOException{
        //作业();
        作业2();

    }

    private static void 作业2() throws IOException {
        InputStreamReader isr = new InputStreamReader(new FileInputStream("D:\\workspace_idea\\resp1\\day1\\src\\N.txt"),"utf-8");
        char b1[]=new char[10];
        int len=0;
        while ((len= isr.read(b1))!=-1){
            System.out.println(new String(b1,0,len));

        }
        isr.close();
        OutputStreamWriter osw=new OutputStreamWriter(new FileOutputStream("D:\\workspace_idea\\resp1\\day1\\src\\N.txt"),"GBK");
        osw.write(97);
        osw.write("你好啊");
        osw.close();
    }

    private static void 作业() throws IOException {
        File f = new File("D:\\HelloWorld.txt");
        if (!f.exists()) {
            f.createNewFile();
        }
        System.out.println("是否是文件：" + f.isFile());
        System.out.println("是否是目的：" + f.isDirectory());
        File f2 = new File("D:\\IOTest");
        if (!f2.exists()) {
            f2.mkdir();
        }
        InputStream is2 = new FileInputStream(f);
        OutputStream os2 = new FileOutputStream("D:\\IOTest\\", true);
        byte b2[] = new byte[100];
        int len = 0;
        while ((len = is2.read(b2)) != -1) {
            os2.write(b2, 0, len);
        }
        os2.close();
        is2.close();
        System.out.println("拷贝结束！");
    }
}
